package dk.itu.samd.group2.tagapastry.util;

import rice.p2p.commonapi.NodeHandle;

public class NodeStatistics {
	
	private int numberOfBytes;
	private int numOfIndexes;
	private int numOfEntriesPerNode;
	private int numOfChildren;
	private NodeHandle handle;
	
	public NodeStatistics(NodeHandle handle) {
		this.handle = handle;
	}
	
	/*
	 * Gets number of bytes used by all indexes on a node
	 */
	public int getNumberOfBytes() {
		return this.numberOfBytes;
	}
	
	public void setNumberOfBytes(int num) {
		this.numberOfBytes = num;
	}
	
	/*
	 * Gets number of indexes stored on a node
	 */
	public int getNumOfIndexes() {
		return this.numOfIndexes;
	}
	
	public void setNumOfIndexes(int num) {
		this.numOfIndexes = num;
	}
	
	/*
	 * Gets number of index entries that are part
	 * of indexes stored on a node. 
	 */
	public int getNumOfEntriesPerNode() {
		return this.numOfEntriesPerNode;
	}
	
	public void setNumOfEntriesPerNode(int num) {
		this.numOfEntriesPerNode = num;
	}
	
	public int getNumOfChildren() {
		return this.numOfChildren;
	}
	
	public void setNumOfChildren(int num) {
		this.numOfChildren = num;
	}
	
	/*
	 * Print just values
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		
		if(getNumberOfBytes() == 0 && 
				getNumOfIndexes() == 0 &&
				getNumOfEntriesPerNode() == 0 &&
				getNumOfChildren() == 0)
			return "";
		
		return String.format("%d %d %d %d", getNumberOfBytes(),
				getNumOfIndexes(),
				getNumOfEntriesPerNode(),
				getNumOfChildren());
	}
	
	/*
	 * Print values with header
	 */
	public static String getHeader() {
		//return "Bytes: Indexes: Entries(Total): Children(Total):";
		return "\r\nLoad per node";
	}
}
